package crm.view.campaign;

import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.border.BevelBorder;
import javax.swing.UIManager;
import javax.swing.JComboBox;
import javax.swing.border.TitledBorder;

@SuppressWarnings({ "unused", "serial" })
public class CampaignManagment extends JPanel
{
	private JButton btnSave;
	private JButton btnUpdate;
	private JButton btnBack;
	private JButton btnSearch;
	private JButton btnForward;
	private JButton btnClear;
	private JTextField tCampName;
	private JComboBox comboCreatedBy;
	private JTextField tStartDate;
	private JTextField tEndDate;
	private JButton[] buttongrp=new JButton[9];
	private JTextArea textAreaDescription;
	private JLabel lblCampaignId;
	private JLabel lblStatus;
	private JButton btnStartDate;
	private JButton btnEndDate;
	private JButton btnStatus;
	private JLabel lblCampaihnStatus;
	private JLabel labelCampaignId;
	
	public CampaignManagment() 
	{
		setBorder(new TitledBorder(null, "Campaign", TitledBorder.LEADING, TitledBorder.TOP, null, Color.DARK_GRAY));
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		this.setBackground(Color.LIGHT_GRAY);
	    this.setPreferredSize(new Dimension(360, 620));
		
		/*
		 * SETTING LABELS
		 */
		 String[] labelsTitle = {"Name: ", "Phone: ", "Email: ", "Address: "};
		 JLabel[] labels=new JLabel[4];
		 
		 for(int i=0;i<labels.length;i++)
		 {
			 labels[i]=new JLabel(labelsTitle[i], JLabel.TRAILING);
			 add(labels[i]);
		 }
		
		lblCampaignId = new JLabel();
		lblCampaignId.setText("0000");
		lblCampaignId.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCampaignId, 5, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.EAST, lblCampaignId, -30, SpringLayout.EAST,this);
		add(lblCampaignId);
			
		labelCampaignId = new JLabel("Campaign Id :");
		labelCampaignId.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, labelCampaignId, 5, SpringLayout.NORTH,this);
		springLayout.putConstraint(SpringLayout.EAST, labelCampaignId, -10, SpringLayout.WEST, lblCampaignId);
		add(labelCampaignId);
		
		lblCampaihnStatus = new JLabel("Campaign Status :");
		lblCampaihnStatus.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCampaihnStatus, 8, SpringLayout.SOUTH, labelCampaignId);
		springLayout.putConstraint(SpringLayout.EAST, lblCampaihnStatus, 0, SpringLayout.EAST, labelCampaignId);
		add(lblCampaihnStatus);
		
		lblStatus = new JLabel("XYZ");
		lblStatus.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblStatus, 6, SpringLayout.SOUTH, lblCampaignId);
		springLayout.putConstraint(SpringLayout.WEST, lblStatus, 0, SpringLayout.WEST, lblCampaignId);
		add(lblStatus);
		 
		JLabel lblCampaignName = new JLabel("Campaign Name");
		lblCampaignName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCampaignName, 40, SpringLayout.SOUTH,lblCampaignId);
		springLayout.putConstraint(SpringLayout.WEST, lblCampaignName, 30, SpringLayout.WEST, this);
		add(lblCampaignName);
		
		tCampName = new JTextField();
		tCampName.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tCampName, 6, SpringLayout.SOUTH, lblCampaignName);
		springLayout.putConstraint(SpringLayout.WEST, tCampName, 30, SpringLayout.WEST,this);
		add(tCampName);
		tCampName.setPreferredSize(new Dimension(300, 23));
		
		
		JLabel lblCreatedBy = new JLabel("Ceated By");
		lblCreatedBy.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCreatedBy, 10, SpringLayout.SOUTH, tCampName);
		springLayout.putConstraint(SpringLayout.WEST, lblCreatedBy, 0, SpringLayout.WEST, lblCampaignName);
		add(lblCreatedBy);
		

		comboCreatedBy = new JComboBox();
		comboCreatedBy.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, comboCreatedBy, 6, SpringLayout.SOUTH, lblCreatedBy);
		springLayout.putConstraint(SpringLayout.WEST, comboCreatedBy, 0, SpringLayout.WEST, lblCampaignName);
		add(comboCreatedBy);
		comboCreatedBy.setPreferredSize(new Dimension(300, 23));
		
		
		
		JLabel lblStartDate = new JLabel("Start Date");
		lblStartDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblStartDate, 10, SpringLayout.SOUTH, comboCreatedBy);
		springLayout.putConstraint(SpringLayout.WEST, lblStartDate, 0, SpringLayout.WEST, lblCampaignName);
		add(lblStartDate);
		
		tStartDate = new JTextField();
		tStartDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tStartDate, 6, SpringLayout.SOUTH, lblStartDate);
		springLayout.putConstraint(SpringLayout.WEST, tStartDate, 0, SpringLayout.WEST, lblCampaignName);
		add(tStartDate);
		tStartDate.setPreferredSize(new Dimension(100, 23));
		
		JLabel lblEndDate = new JLabel("End Date");
		lblEndDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblEndDate, 10, SpringLayout.SOUTH, tStartDate);
		springLayout.putConstraint(SpringLayout.WEST, lblEndDate, 0, SpringLayout.WEST, lblCampaignName);
		add(lblEndDate);
		
		btnStartDate = new JButton("SD");
		springLayout.putConstraint(SpringLayout.NORTH, btnStartDate, 0, SpringLayout.NORTH, tStartDate);
		springLayout.putConstraint(SpringLayout.WEST, btnStartDate, 10, SpringLayout.EAST, tStartDate);
		add(btnStartDate);
		
		tEndDate = new JTextField();
		tEndDate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, tEndDate, 6, SpringLayout.SOUTH, lblEndDate);
		springLayout.putConstraint(SpringLayout.WEST, tEndDate, 0, SpringLayout.WEST, lblCampaignName);
		add(tEndDate);
		tEndDate.setPreferredSize(new Dimension(100, 23));
		
		btnEndDate = new JButton("LD");
		springLayout.putConstraint(SpringLayout.NORTH, btnEndDate, 0, SpringLayout.NORTH, tEndDate);
		springLayout.putConstraint(SpringLayout.WEST, btnEndDate, 10, SpringLayout.EAST,tEndDate);
		add(btnEndDate);
		
		JLabel lblDescription = new JLabel("Description");
		lblDescription.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblDescription, 10, SpringLayout.SOUTH, tEndDate);
		springLayout.putConstraint(SpringLayout.WEST, lblDescription, 0, SpringLayout.WEST, lblCampaignName);
		add(lblDescription);
		
		textAreaDescription = new JTextArea();
		textAreaDescription.setRows(2);
		textAreaDescription.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, textAreaDescription, 6, SpringLayout.SOUTH, lblDescription);
		springLayout.putConstraint(SpringLayout.WEST, textAreaDescription, 0, SpringLayout.WEST, lblCampaignName);
		add(textAreaDescription);
		textAreaDescription.setPreferredSize(new Dimension(300, 50));
		
		btnStatus = new JButton("Mark Deactivate");
		btnStatus.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnStatus, 20, SpringLayout.SOUTH, textAreaDescription);
		springLayout.putConstraint(SpringLayout.WEST, btnStatus, 30, SpringLayout.WEST, this);
		add(btnStatus);
			
		JPanel panel = new JPanel();
		springLayout.putConstraint(SpringLayout.NORTH, panel, 10, SpringLayout.SOUTH, btnStatus);
		springLayout.putConstraint(SpringLayout.WEST, panel, 30, SpringLayout.WEST,this);
		add(panel);
		panel.setPreferredSize(new Dimension(300, 80));
		GridLayout g=new GridLayout(2,3,2,2);
		panel.setLayout(g);

		btnSave = new JButton("Save");
		btnSave.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnSave);
		btnSave.setActionCommand("SAVE");
		buttongrp[0]=btnSave;
		
		btnClear = new JButton("Clear");
		btnClear.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnClear);
		btnClear.setActionCommand("CLEAR");
		buttongrp[1]=btnClear;
		
		btnUpdate = new JButton("Update");
		btnUpdate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnUpdate);
		btnUpdate.setActionCommand("UPDATE");
		buttongrp[2]=btnUpdate;
		
		btnBack = new JButton("  <<  ");
		btnBack.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnBack);
		btnBack.setActionCommand("<< ");
		buttongrp[3]=btnBack;
		
		btnSearch = new JButton("Search");
		btnSearch.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnSearch);
		btnSearch.setActionCommand("SEARCH");
		buttongrp[4]=btnSearch;
		
		btnForward = new JButton(">>");
		btnForward.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		panel.add(btnForward);
		btnForward.setActionCommand(">>");
		buttongrp[5]=btnForward;
		
		buttongrp[6]=btnStatus;
		buttongrp[6].setActionCommand("status");
		
		buttongrp[7]=this.btnEndDate;
		buttongrp[7].setActionCommand("endDate");
		
		buttongrp[8]=this.btnStartDate;
		buttongrp[8].setActionCommand("startDate");
		
		
		
		
	
	
	
	}
	
	
	
	public JButton getBtnSave() {
		return btnSave;
	}



	public void setBtnSave(JButton btnSave) {
		this.btnSave = btnSave;
	}



	public JButton getBtnUpdate() {
		return btnUpdate;
	}



	public void setBtnUpdate(JButton btnUpdate) {
		this.btnUpdate = btnUpdate;
	}



	public JButton getBtnBack() {
		return btnBack;
	}



	public void setBtnBack(JButton btnBack) {
		this.btnBack = btnBack;
	}



	public JButton getBtnSearch() {
		return btnSearch;
	}



	public void setBtnSearch(JButton btnSearch) {
		this.btnSearch = btnSearch;
	}



	public JButton getBtnForward() {
		return btnForward;
	}



	public void setBtnForward(JButton btnForward) {
		this.btnForward = btnForward;
	}



	public JButton getBtnClear() {
		return btnClear;
	}



	public void setBtnClear(JButton btnClear) {
		this.btnClear = btnClear;
	}



	public JTextField gettCampName() {
		return tCampName;
	}



	public void settCampName(JTextField tCampName) {
		this.tCampName = tCampName;
	}



	public JComboBox getComboCreatedBy() {
		return comboCreatedBy;
	}



	public void setComboCreatedBy(JComboBox comboCreatedBy) {
		this.comboCreatedBy = comboCreatedBy;
	}



	public JTextField gettStartDate() {
		return tStartDate;
	}



	public void settStartDate(JTextField tStartDate) {
		this.tStartDate = tStartDate;
	}



	public JTextField gettEndDate() {
		return tEndDate;
	}



	public void settEndDate(JTextField tEndDate) {
		this.tEndDate = tEndDate;
	}



	public JTextArea getTextAreaDescription() {
		return textAreaDescription;
	}



	public void setTextAreaDescription(JTextArea textAreaDescription) {
		this.textAreaDescription = textAreaDescription;
	}



	public JLabel getLblCampaignId() {
		return lblCampaignId;
	}



	public void setLblCampaignId(JLabel lblCampaignId) {
		this.lblCampaignId = lblCampaignId;
	}



	public JLabel getLblStatus() {
		return lblStatus;
	}



	public void setLblStatus(JLabel lblStatus) {
		this.lblStatus = lblStatus;
	}



	public JButton getBtnStartDate() {
		return btnStartDate;
	}



	public void setBtnStartDate(JButton btnStartDate) {
		this.btnStartDate = btnStartDate;
	}



	public JButton getBtnEndDate() {
		return btnEndDate;
	}



	public void setBtnEndDate(JButton btnEndDate) {
		this.btnEndDate = btnEndDate;
	}



	public JButton getBtnStatus() {
		return btnStatus;
	}



	public void setBtnStatus(JButton btnStatus) {
		this.btnStatus = btnStatus;
	}



	public JLabel getLblCampaihnStatus() {
		return lblCampaihnStatus;
	}



	public void setLblCampaihnStatus(JLabel lblCampaihnStatus) {
		this.lblCampaihnStatus = lblCampaihnStatus;
	}



	public JLabel getLabelCampaignId() {
		return labelCampaignId;
	}



	public void setLabelCampaignId(JLabel labelCampaignId) {
		this.labelCampaignId = labelCampaignId;
	}



	public void actionListener(ActionListener al)
	{
		for(int i=0;i<buttongrp.length;i++)
		{
			buttongrp[i].addActionListener(al);
			System.out.println(buttongrp[i].getActionCommand());
		}
	}
}
